﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CamposInventory
{
    public partial class FrmMain : Form
    {
        
        public FrmMain()
        {
            InitializeComponent();
            this.Load += new EventHandler(FrmMain_Load);
            mnuProductOrderMenu.Click += new EventHandler(mnuProductOrderMenu_Click);
            mnuViewmanager.Click += new EventHandler(mnuViewmanager_Click);
            mnuLogout.Click += new EventHandler(mnuLogout_Click);
            mnuUsermanager.Click += new EventHandler(mnuUsermanager_Click);
            mnuLogin.Click += new EventHandler(mnuLogin_Click);
            mnuChangepassword.Click += new EventHandler(mnuChangepassword_Click);
            mnuExit.Click += new EventHandler(mnuExit_Click);
            mnuProductlist.Click += new EventHandler(mnuProductlist_Click);
            mnuUpdateprod.Click += new EventHandler(mnuUpdateprod_Click);
            mnuProdlevel.Click += new EventHandler(mnuProdlevel_Click);
            
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();
        }

        void mnuProdlevel_Click(object sender, EventArgs e)
        {
            frmInvenntorylevel frmlevel = new frmInvenntorylevel();
            frmlevel.Show();
        }

        void mnuUpdateprod_Click(object sender, EventArgs e)
        {
            frmUpdateproduct frmuprod = new frmUpdateproduct(this);
            frmuprod.MdiParent = this;
            frmuprod.Show();
        }

        void mnuProductOrderMenu_Click(object sender, EventArgs e)
        {
            frmProductOrderMenu frmPOM = new frmProductOrderMenu(this);
            frmPOM.MdiParent = this;
            frmPOM.Show();
        }

     
        void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;

            this.lbltime.Text = dt.ToString();
        }

        void mnuProductlist_Click(object sender, EventArgs e)
        {
            frmManagestock frmlist = new frmManagestock(this);
            frmlist.MdiParent = this;
            frmlist.Show();
        }

        void mnuExit_Click(object sender, EventArgs e)
        {
             DialogResult result;
            result = MessageBox.Show("Are you sure to exit ? ", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                Application.Exit();

            }
            else
            {
                this.Refresh();
            
            }
        }

        

        void mnuViewmanager_Click(object sender, EventArgs e)
        {
            frmViewmanager frmVManager = new frmViewmanager(this);
            frmVManager.MdiParent = this;
            frmVManager.Show();
        }

        void mnuChangepassword_Click(object sender, EventArgs e)
        {
            frmChangepass frmchange = new frmChangepass(this);
            frmchange.MdiParent = this;
            frmchange.Show();
        }

        void mnuLogin_Click(object sender, EventArgs e)
        {
            frmlogin login = new frmlogin(this);
            login.MdiParent = this;
            login.Show();
        }

        void mnuUsermanager_Click(object sender, EventArgs e)
        {
            frmUsermanager frmUsem = new frmUsermanager(this);
            frmUsem.MdiParent = this;
            frmUsem.Show();
            
        }

        void mnuLogout_Click(object sender, EventArgs e)
        {
            DialogResult result;
            result = MessageBox.Show("Maglalag out ka na talaga?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                frmlogin login = new frmlogin(this);
                login.MdiParent = this;
                login.Show();
                mnuLogin.Enabled = true;
                mnuLogout.Enabled = false;
                mnuManager.Enabled = false;
                mnuInventory.Enabled = false;
                mnuReport.Enabled = false;
                lblonline.Text = "";
            }
            else
            {
                this.Show();

            }
        }

        void FrmMain_Load(object sender, EventArgs e)
        {
            frmlogin login = new frmlogin(this);
            login.MdiParent = this;
            login.Show();
            mnuPOS.Enabled = false;
            mnuManager.Enabled = false;
            mnuInventory.Enabled = false;
            mnuReport.Enabled = false;
            mnuLogout.Enabled = false;
            lblonline.Text = "";

        }
       
       public void mnuManupulate(string accesslevel)
       {
           switch (accesslevel)
           {
               case "1": 
                   mnuManager.Enabled = true;
                   mnuInventory.Enabled = true;
                   mnuUsermanager.Enabled = true;
                   mnuLogout.Enabled = true;
                   mnuLogin.Enabled = false;
                   mnuReport.Enabled =true;
                   mnuPOS.Enabled = true;
                   break;
               case "2": 
                   mnuManager.Enabled = true;
                   mnuUsermanager.Enabled = false;
                   mnuInventory.Enabled = true;
                   mnuLogout.Enabled = true;
                   mnuLogin.Enabled = false;
                   mnuReport.Enabled = true;
                   mnuPOS.Enabled = true;
                   break;
               
           }
       }


       public void passdata(string pass)
       {

           lblonline.Text = pass;
       
       
       }

       private void mnuInventory_Click(object sender, EventArgs e)
       {

       }

    }
}
